local sk__huoshui = fk.CreateSkill {

  name = "sk__huoshui",

  tags = {  },

}



sk__huoshui:addEffect(fk.EventPhaseStart, {
  name = "sk__huoshui",
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(sk__huoshui.name) and player.phase == Player.Finish and
      table.find(player.room:getOtherPlayers(player), function(p)
        return p.chained and not p:isNude() or not p.faceup
      end)
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, sk__huoshui.name, nil, "#sk__huoshui-invoke")
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = table.map(table.filter(room:getOtherPlayers(player), function(p)
      return p.chained and not p:isNude() or not p.faceup
    end), Util.IdMapper)
    room:doIndicate(player.id, targets)
    for _, p in ipairs(room:getOtherPlayers(player)) do
      if p.chained and not p:isNude() and not p.dead and not player.dead then
        local card = room:askForCardChosen(player, p, "he", sk__huoshui.name, "#sk__huoshui-choose::"..p.id)
        room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, sk__huoshui.name, nil, false, player)
      end
    end
    for _, p in ipairs(room:getOtherPlayers(player)) do
      if not p.faceup then
        room:damage{
          from = player,
          to = p,
          damage = 1,
          skillName = sk__huoshui.name,
        }
      end
    end
  end,
})

return sk__huoshui